package com.sp.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.sp.model.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 管理员 Mapper
 *
 * @author tong
 */
@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {

    /**
     * 连表分页查询
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    IPage<Employee> page(IPage<Employee> page, @Param(Constants.WRAPPER) Wrapper<Employee> queryWrapper);

    /**
     * 连表分页查询，条件有角色
     *
     * @param page
     * @param queryWrapper
     * @param roleId       查询时，传入的是roleId
     * @return
     */
    IPage<Employee> pageWithRole(IPage<Employee> page, @Param(Constants.WRAPPER) QueryWrapper<Employee> queryWrapper, @Param("roleId") String roleId);

    /**
     * 连表根据id查询
     *
     * @param id
     * @return
     */
    Employee getById(@Param("id") Integer id);

    /**
     * 连表根据username查询
     *
     * @param username
     * @return
     */
    Employee selectByUsername(@Param("username") String username);

}
